package com.lingshu.app.repository;

import android.util.Log;

import androidx.lifecycle.MutableLiveData;

import com.lingshu.app.model.register.RegisterQueryRequest;
import com.lingshu.app.model.register.RegisterQueryResponse;
import com.lingshu.app.network.RetrofitMobileClient;
import com.lingshu.app.service.RegisterService;

import javax.inject.Inject;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @author 于定金
 * @version 1.0
 * @Date 2024/1/9 14:55
 * @Description
 */
public class ScreeningRegisterRepository {
    public final MutableLiveData<RegisterQueryResponse> registerInfo = new MutableLiveData<>();

    @Inject
    ScreeningRegisterRepository() {
    }

    public MutableLiveData<RegisterQueryResponse> getRegisterInfo(RegisterQueryRequest queryRequest) {
        RetrofitMobileClient.getInstance().getService(RegisterService.class).getRegisterList(queryRequest).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(returnObject -> {
            if (returnObject.isSuccess()) {
                registerInfo.postValue(returnObject.getData());
            }
        }, throwable -> {
            Log.d(ScreeningRegisterRepository.class.getSimpleName(), throwable.getMessage());
        });
        return registerInfo;
    }
}
